﻿using System.Collections.Generic;
using FamilyBook.Core.Entities;
using FamilyBook.Core.Services;

namespace FamilyBook.UI.WPF.ViewModels
{
    public class AccountDetailsViewModel : BaseDetailsViewModel<Account>
    {
        private readonly AccountService<Account> _acctSrv;
        private readonly GeneralService<Product, int> _prodSrv;

        public AccountDetailsViewModel(Account account, IList<Currency> currencies, AccountService<Account> acctSrv, GeneralService<Product, int> prodSrv)
            : base(account)
        {
            this.Currencies = currencies;
            _acctSrv = acctSrv;
            _prodSrv = prodSrv;
        }

        public string Number
        {
            get { return Model.Number; }
            set
            {
                Model.Number = value;
                RaisePropertyChanged(Number);
            }
        }
        public string DisplayedName
        {
            get { return Model.DisplayedName; }
            set
            {
                Model.DisplayedName = value;
                RaisePropertyChanged(DisplayedName);
            }
        }
        public string Description
        {
            get { return Model.Description; }
            set
            {
                Model.Description = value;
                RaisePropertyChanged(Description);
            }
        }

        public IList<Currency> Currencies { get; private set; }
        public Currency SelectedCurrency
        {
            get { return Model.Currency; }
            set
            {
                Model.Currency = value;
                RaisePropertyChanged(() => SelectedCurrency);
            }
        }

        public Counterparty Custodian
        {
            get { return Model.Custodian; }
        }
        public bool IsDefault
        {
            get { return Model.IsDefault; }
            set
            {
                Model.IsDefault = value;
                RaisePropertyChanged(() => IsDefault);
            }
        }

        public TransactionsListViewModel OutgoingTransactions
        {
            get { return new TransactionsListViewModel(Model.OutgoingTransactions, _acctSrv, _prodSrv); }
        }
        public TransactionsListViewModel IncomingTransactions
        {
            get { return new TransactionsListViewModel(Model.IncomingTransactions, _acctSrv, _prodSrv); }
        }
    }
}
